package com.aaa.moneymanage.services.impl;

import com.aaa.entity.OrderCharge;
import com.aaa.entity.OrderChargeItem;
import com.aaa.moneymanage.dao.MoneyinDao;
import com.aaa.moneymanage.dao.OrderChangeItemDao;
import com.aaa.moneymanage.services.MoneyinServices;
import com.aaa.moneymanage.vo.MoneyVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：XiaoxXuan
 * @date ：Created in 2023/3/22 17:09
 * @description：
 * @modified By：
 */
@Service
public class MoneyinServicesImpl implements MoneyinServices {

    @Resource
    private MoneyinDao moneyinDao;
    @Resource
    private OrderChangeItemDao orderChangeItemDao;

    /** * @create by: XiaoXuan
     * @description: 收费列表查询所有 
     * @create time: 2023/4/7 20:03
     * * @param currentPage
     * @param pageSize
     * @param moneyVo 
     * @return com.aaa.vo.Result<com.baomidou.mybatisplus.core.metadata.IPage < com.aaa.entity.OrderCharge>> 
     */
    @Override
    public Result<IPage<OrderCharge>> getMoneyIn(Integer currentPage, Integer pageSize, MoneyVo moneyVo) {

        IPage<OrderCharge> page=new Page<>(currentPage,pageSize);

        QueryWrapper<OrderCharge> wrapper=new QueryWrapper<>();
        if(StringUtils.hasText(moneyVo.getPatientName())){
            wrapper.like("patient_name",moneyVo.getPatientName());
        }
        if(StringUtils.hasText(moneyVo.getRegId())){
            wrapper.eq("reg_id",moneyVo.getRegId());
        }
        IPage<OrderCharge> orderChargeIPage = moneyinDao.selectPage(page, wrapper);
        return new Result<IPage<OrderCharge>>(200,"查询收费管理成功",orderChargeIPage);

    }


    /** * @create by: XiaoXuan
     * @description:  前端查看详情调用方法，查询数据通过orderid
     * @create time: 2023/3/27 9:25
     * * @param orderId 
     * @return com.aaa.vo.Result<java.util.List < com.aaa.moneymanage.entity.OrderChargeItem>> 
     */
    @Override
    public Result<List<OrderChargeItem>> selectOneByOrderId(String orderId) {
        QueryWrapper<OrderChargeItem> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId);
        List<OrderChargeItem> orderChargeItems = orderChangeItemDao.selectList(wrapper);
        return new Result<>(200,"查询支付订单成功",orderChargeItems);
    }

    /** * @create by: XiaoXuan
     * @description:  插入收费查询列表
     * @create time: 2023/4/7 20:02
     * * @param orderCharge 
     * @return boolean 
     */
    @Override
    public boolean insertOrderCharge(OrderCharge orderCharge) {
        return moneyinDao.insertOrderCharge(orderCharge);
    }

    /** * @create by: XiaoXuan
     * @description: 插入收费查询的查看详情列表 
     * @create time: 2023/4/7 20:02
     * * @param orderChargeItem 
     * @return boolean 
     */
    @Override
    public boolean insertOrderChargeItem(OrderChargeItem orderChargeItem) {
        return orderChangeItemDao.insertOrderChargeItem(orderChargeItem);
    }


}